--Redzone RPG
--By Kylegar
include("hud.lua")
include("shared.lua")
include("cl_vgui.lua")

function movecam (ply , origin , angles , fov )
	
	playerangles = Angle(0 , angles.yaw , angles.roll)
	
	
	local view = {}
	local trace = {}
	trace.start = origin
	trace.endpos = origin + Vector(0,0,350)
	trace.filter = LocalPlayer()
	local traceres = util.TraceLine(trace)
	
	if(traceres.Hit) then
	 local diff = traceres.HitPos.z/(origin.z + 350)
	 draw.DrawText(tostring(diff) , "ScoreboardText" , 1 , 1 , Color(255 , 255 , 255 , 255) , 1)
	 view.origin = traceres.HitPos - Vector(0,0,10)
	 view.angles = playerangles + Angle((65-(1/(diff*65))),0,0)
	else
	 view.origin = trace.endpos
	 view.angles = playerangles + Angle(65,0,0)	
	end
		
	return view
	
end
hook.Add("CalcView" , "movecam", movecam)


function lockview()	
		local eyes = LocalPlayer():EyeAngles()		
		LocalPlayer():SetEyeAngles( Angle(0, eyes.yaw , eyes.roll))	
end
hook.Add("Think" , "lockview" , lockview)

function GM:PlayerBindPress(ply , bind, pressed)
	
	if(string.find(bind,"+menu_context")) then
		PlayerSkillPanel()
	end
	if(string.find(bind,"-menu_context"))then
	end

end




function aimhack()
   if(LocalPlayer():IsValid()) then
	local ang = LocalPlayer():GetAngles()
	local pos = LocalPlayer():GetPos()
	local tres = {}
	
	tres.start = pos
	tres.endpos = pos + (ang:Forward() * 350)
	tres.filter = LocalPlayer()
	
	local eyetr = util.TraceLine(tres)
	
	
	if(eyetr.HitNonWorld) then
	
	 if(eyetr.Entity:IsValid()) then
	  Msg("  I hit "..eyetr.Entity:GetClass().."\n")
	  local entpos = eyetr.Entity:OBBCenter()
	  local angle = (LocalPlayer():GetPos() - entpos):Normalize():Angle()
	  LocalPlayer():SetAngles(angle)
	 end
	end
   end  

end
hook.Add("Think", "rzaimhack",aimhack)


